/**
 * 
 */
package se.cirrus.base;

import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;

/**
 * @author Winquman
 *
 */
public class CirrusLogFormatter extends Formatter {

	/**
	 * 
	 */
	public CirrusLogFormatter() {
		
	}

	/* (non-Javadoc)
	 * @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
	 */
	@Override
	public String format(LogRecord lr) {
		String s;
		
		Date date = new Date(lr.getMillis());
		DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
		String dateFormatted = formatter.format(date);
		
		s = dateFormatted + " " + lr.getLevel().toString() + " (" + lr.getThreadID() + ")[" +
				lr.getSourceClassName() + "." + lr.getSourceMethodName() + "] " + lr.getMessage() + "\r\n";  
		
		return s;
	}

}
